package show.me.the.money.keyserver;

import java.io.Serializable;

public class ServerInfo implements Serializable{

	private static final long serialVersionUID = 1L;
	private String hostName = "";
	private int port;
	private int isAlive;
	private int counter = 0;
	
	public ServerInfo(){
		
	}
	
	public ServerInfo(String host, int port, int isAlive){
		this.hostName = host;
		this.port = port;
		this.isAlive = isAlive;
	}
	
	public String getHostName() {
		return hostName;
	}

	public void setHostName(String hostName) {
		this.hostName = hostName;
	}

	public int getPort() {
		return port;
	}

	public void setPort(int port) {
		this.port = port;
	}
	
	public int getIsAlive() {
		return isAlive;
	}

	public void setIsAlive(int isAlive) {
		this.isAlive = isAlive;
	}
	

	public int getCounter() {
		return counter;
	}

	public void setCounter(int counter) {
		this.counter = counter;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj == null){
			return false;
		}else if(obj.getClass() == this.getClass()){
			ServerInfo s = (ServerInfo)obj;
			return s.hostName.equals(hostName) && s.getPort() == port;
		}
		return false;
	}
	
	@Override
	public String toString() {
		if("".equals(this.hostName)){
			return this.counter+"";
		}
		return this.hostName +"--"+ this.port;
	}
	
}
